import request from '@/utils/request'

export default {
  getRoleList(searchModel) {
    return request({
      url: '/role/list',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        roleName: searchModel.roleName
      }
    })
  },
  addRole(data) {
    return request({
      url: '/role',
      method: 'post',
      data
    })
  },
  editRole(data) {
    return request({
      url: '/role',
      method: 'put',
      data
    })
  },
  saveRole(data) {
    if (data.roleId == null || data.roleId === undefined) {
      return this.addRole(data)
    }
    return this.editRole(data)
  },
  getRoleInfo(id) {
    return request({
      url: '/role/' + id,
      method: 'get'
    })
  },
  deleteRole(id) {
    return request({
      url: '/role/' + id,
      method: 'delete'
    })
  },
  getRoleListAll() {
    return request({
      url: '/role/all',
      method: 'get'
    })
  }
}
